package com.spsoft.vatoutinv.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.spsoft.core.annotation.AnonymousAccess;
import com.spsoft.core.annotation.Log;
import com.spsoft.core.enums.LogActionType;
import com.spsoft.core.enums.LogMenuEnum;
import com.spsoft.core.model.Result;
import com.spsoft.vatoutinv.model.dto.transflowfindinvoice.TransFlowRecallInvoiceQueryDTO;
import com.spsoft.vatoutinv.model.vo.transflowfindinvoice.TransFlowRecallInvoiceRespVO;
import com.spsoft.vatoutinv.model.vo.transflowfindinvoice.TransFlowRecallInvoiceInfoVO;
import com.spsoft.vatoutinv.service.nvatoutinvoice.NvatOutInvoiceService;
import com.spsoft.vatoutinv.service.vmsnvattrandtadvaltax.VmsNvatTrandtadvaltaxsepService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 交易流水追溯发票
 */
@Api(tags = {"交易流水追溯发票"})
@RequiredArgsConstructor
@Validated
@Slf4j
@RestController
@RequestMapping("/transflowRecallinvoice/")
public class TransFlowRecallInvoiceController {

    private final VmsNvatTrandtadvaltaxsepService vmsNvatTrandtadvaltaxsepService;
    private final NvatOutInvoiceService nvatOutInvoiceService;
    /**
     * 交易流水追溯发票-查询交易流水信息
     * @param queryDTO
     * @return
     */
    @ApiOperation("交易流水追溯发票-查询交易流水信息")
    @AnonymousAccess(value = "/queryTransflow", method = RequestMethod.POST, permissionCode = "VMS_JYLSZS")
    @Log(value = "交易流水追溯发票-查询交易流水信息", type = LogActionType.SELECT, menuName = LogMenuEnum.VMS_TRANSFLOW_INIVOICE)
    public Result<IPage<TransFlowRecallInvoiceRespVO>> queryTransflow(@RequestBody  @Validated TransFlowRecallInvoiceQueryDTO queryDTO) {
        return vmsNvatTrandtadvaltaxsepService.queryTransflow(queryDTO);
    }

    /**
     * 交易流水追溯发票-查询发票信息
     * @param rdid
     * @return
     */
    @ApiOperation("交易流水追溯发票-查询发票信息")
    @AnonymousAccess(value = "/queryInvoice", method = RequestMethod.GET, permissionCode = "VMS_JYLSZS")
    @Log(value = "交易流水追溯发票-查询发票信息", type = LogActionType.SELECT, menuName = LogMenuEnum.VMS_TRANSFLOW_INIVOICE)
    public Result<List<TransFlowRecallInvoiceInfoVO>> queryInvoiceByRdid(@RequestParam(value = "rdid") Integer rdid) {
        return nvatOutInvoiceService.queryInvoiceByRdid(rdid);
    }
}
